package cn.shen.edit.controller;


import cn.shen.edit.common.WebResult;
import cn.shen.edit.common.WebResultUtil;
import cn.shen.edit.entity.User;
import cn.shen.edit.entity.Wallet;
import cn.shen.edit.mapper.UserMapper;
import cn.shen.edit.mapper.WalletMapper;
import cn.shen.edit.service.WalletService;
import cn.shen.edit.vo.DetailVo;
import cn.shen.edit.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private WalletMapper walletMapper;

    @Autowired
    private WalletService walletService;

    @PostMapping("/balance")
    public Long selectBalance(UserVo vo){
        return userMapper.selectBalance(vo.getUserId());
    }


    /** 消费接口*/
    @PostMapping("/consumption")
    public WebResult consumption(UserVo vo, Long amount){
        return walletService.consumption(vo.getUserId(),amount);
    }

    /** 退款接口*/
    @PostMapping("/refund")
    public WebResult refund(UserVo vo, Long amount){
        return walletService.refund(vo.getUserId(),amount);
    }

    /** 查询金额变动明细*/
    @PostMapping("/detail")
    public WebResult detail(DetailVo vo){
        return walletService.detail(vo);
    }









}
